import {
    Base
} from '../../utils/base.js';
const addUserAddress = '/ddaigo-platform/user/addUser'
const getUserAddressById = '/ddaigo-platform/user/getUserAddressById'
const updateUserAddress = '/ddaigo-platform/user/updateUserAddress'
const getAreaByPid = '/ddaigo-platform/area/getAreaByPid'

class Address extends Base {
    constructor() {
        super()
    }
    //获取省市区
    getThree(params, callback) {
        var reType = 'POST';
        this.commonRequest(getAreaByPid, reType, params, callback);
    }

    //获取用户地址
    getUserAddress(params, callback) {
        var url = '/ddaigo-platform/user/getUserAddress';
        var reType = 'POST';
        this.commonRequest(url, reType, params, callback);
    }
    //新增用户地址
    addUserAddress(params, callback) {
        var url = '/ddaigo-platform/user/addUserAddress';
        var reType = 'POST';
        this.commonRequest(url, reType, params, callback);
    }
    //编辑用户地址
    updateUserAddress(params, callback) {
        var url = '/ddaigo-platform/user/updateUserAddress';
        var reType = 'POST';
        this.commonRequest(url, reType, params, callback);
    }
    // 根据id获取单个地址
    getUserAddressById(params, callback) {
        var url = '/ddaigo-platform/user/getUserAddressById';
        var reType = 'POST';
        this.commonRequest(url, reType, params, callback);
    }
    commonRequest(url, reType, params, callback) {
        var that = this;
        var param = {
            url: url,
            type: reType,
            data: params,
            sCallback: function (data) {
                typeof callback == 'function' && callback(data);
            },
            eCallback: data => {
                callback && callback({
                    status: false
                });
            }
        };
        this.request(param);
    }

}
module.exports = {
    Address
}